package com.codeyang.config;

import com.codeyang.constant.QueueConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述: MQ配置类
 *
 * @author CodeYang_Site
 * @version 2021/5/30 11:50
 */
@Configuration
public class RabbitMqConfig {

    /**
     * 创建手机绑定队列
     *
     * @return
     */
    @Bean
    public Queue phoneQueue() {
        return new Queue(QueueConstant.PHONE_SEN_QUEUE);
    }

    /**
     * 创建手机绑定交换机 直连
     *
     * @return
     */
    @Bean
    public DirectExchange phoneEx() {
        return new DirectExchange(QueueConstant.PHONE_SEN_EX);
    }

    /**
     * 创建绑定关系
     *
     * @return
     */
    @Bean
    public Binding phoneBind() {
        return BindingBuilder.bind(phoneQueue()).to(phoneEx()).with(QueueConstant.PHONE_SEN_KEY);
    }

    //------ 创建微信三件套-------

    @Bean
    public Queue wechatQueue() {
        return new Queue(QueueConstant.WECHAT_MSG_QUEUE);
    }

    @Bean
    public DirectExchange wechatEx() {
        return new DirectExchange(QueueConstant.WECHAT_MSG_EXCHANGE);
    }

    @Bean
    public Binding wechatBind() {
        return BindingBuilder.bind(wechatQueue()).to(wechatEx()).with(QueueConstant.WECHAT_MSG_KEY);
    }


}
